package Lower_Type_Bounds

/**
  *
  * Created by juntzhan on 2015/7/24.
  */
case class ListNode[+T](h: T, t: ListNode[T]) {
  def head: T = h

  def tail: ListNode[T] = t

  def prepend[U >: T](elem: U): ListNode[U] =
    ListNode(elem, this)
}

object LowerBoundTest extends App {
  val empty: ListNode[Null] = ListNode(null, null)
  val strList: ListNode[String] = empty.prepend("hello")
    .prepend("world")
  val anyList: ListNode[Any] = strList.prepend(12345)
}
